<?php
// Start session management and include necessary functions
require_once('../dao/database.php');
require_once('../dao/user_db.php');
require_once('../util/Validation.php');
require_once '../dao/KilometerEntryDAO.php';

$action = 'show_entry';

session_start();

// Perform the specified action
switch($action) {
    case 'show_entry':
        $count = KilometerEntryDAO::getCountAll();
        $gesamtPages = ceil(intval($count)/Constants::VAR_PAGE_SIZE);
        $newNextPage = 0;
        
        $from = 0;
        
        if (isset($_GET['page'])) {
            $nextPage = $_GET['page'];
            if (is_numeric($nextPage)){
                if (intval($nextPage) >= 0){ 
                        if ( intval($nextPage) < $gesamtPages ){
                            $from = $nextPage * Constants::VAR_PAGE_SIZE;
                            $newNextPage = $nextPage;
                        }
                }
            }
        }
        $entries = KilometerEntryDAO::getRoutesPinnEntries($from, Constants::VAR_PAGE_SIZE);
        
        include('entryView.php');
        break;
}
?>